package cn.com.dcsgo.interceptors;

import feign.RequestInterceptor;
import feign.RequestTemplate;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

/**
 * Feign请求拦截器，用于在服务间调用时添加特定的请求头标识
 */
@Component
@ConditionalOnClass(WebMvcConfigurationSupport.class)
public class FeignRequestInterceptor implements RequestInterceptor {

    @Override
    public void apply(RequestTemplate template) {
        // 添加Feign调用标识
        template.header("X-Feign-Call", "true");
    }
}